為達到節省葉節點指向NULL的空間浪費
void print(tree_p root) {
printf("\n---------------------------------\n");
printf("\nInorder:\n");
new_search(root);
inorder(root);
}
void inorder(tree_p root) {
if (root != NULL) {
if(root->t_left==false){
inorder(root->left);
}
show_line(root);
if (root->t_right == false) {
inorder(root->right);
}
}
}
void show_line(tree_p point) {
printf("\n----------%d----------", point->data);
get_L(point);
get_R(point);
}
原樹示意圖:
結果顯示:
LR為0表示該分支存在連接節點
LR為1表示該分支為NULL,於是引線連接回去